package com.yycx.module.bus.provider.handler.haiying.tasktodo.settle.saleman;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.constants.CommonConstants;
import com.yycx.common.mybatis.interceptor.SaveInterceptor;
import com.yycx.common.mybatis.query.CriteriaSave;
import com.yycx.module.bus.client.entity.BusPayment;
import com.yycx.module.bus.provider.service.hy.BusHyorderInoviceDetailsService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 支付给市场保存扩展器
 *
 * @author zyf
 */
@Component
public class HySettlePaySubPaymentSaveHandler implements SaveInterceptor<BusPayment> {

    @Resource
    private BusHyorderInoviceDetailsService orderInoviceDetailsService;

    @Override
    public void prepare(CriteriaSave cs, EntityMap entityMap, BusPayment payment) {
        payment.setPaymentState(CommonConstants.INT_2);
    }

    @Override
    public void complete(CriteriaSave cs, EntityMap params, BusPayment entity) {
        Date payDate = entity.getPayDate();
        //更新结算信息
        orderInoviceDetailsService.updatePayInfo(entity.getPaymentId(), payDate);
    }
}
